"""
函数：
"""

# def buy_cai():
#     print("1.打车")
#     print("2.去菜市场")
#     print("3.讨价还价")
#     print("4.回家")

# buy_cai()
# print("哄孙子")

# def maren(name,value):
#     print("1.怒目而视"+name+" 说："+value)
#
# maren("张三","你有病")

# def jisuan(a,opt,b):
#     if opt == "+":
#         print(a+b)
#     elif opt == "-":
#         print(a-b)
#     elif opt == "*":
#         print(a*b)
#     elif opt == "/":
#         print(a/ b)
#     else:
#         print("滚犊子")
#
#
# jisuan(999,"+",666)
# jisuan(999,"-",666)
# jisuan(999,"*",666)
# jisuan(999,"/",666)
# jisuan(999,"&^",666)

# def luru(name,age,gender="男"):
#     print(name,age,gender)
#
# luru("张三",22)
# luru("妹子",18,"女")


# def chi(*food):
#     print(food)
#
# chi("大米饭","烧茄子")

# def chi(**food):
#     print(food)
#
# chi(fu="木须肉",zhu="米饭")

# def func(a,b,*args,c="hh",**kwargs):
#     print(a,b,args,c,kwargs)
#
# func(1,2,3,4,5,6,7,8,9,c="aini",hello=456,hhlo=789)

# stu_lst = ["流川枫","樱木","大老王","二老王"]
# def func(*args):
#     print(args)
#
# func(*stu_lst

# def fun1():
#     return 1,2,3,4
#
# ref=fun1();
# print(ref)


# def func1():
#     # b = 20
#     def func2():
#         print("123")
#     # print(b)
#     return func2
#
# a=func1();
# a()

# def func(an):
#     # print(an)
#     an()
#
# def target():
#     print("我是target")
#
# func(target)
# a = 10;
#
# def func():
#     global a
#     a = 20
#
# func()
#
# print(a)

# def func1():
#     a = 10
#     def func2():
#         nonlocal a
#         a=20
#     func2()
#     print(a)
#
# func1()

# def func():
#     a = 10
#     def inner():
#         nonlocal a
#         a += 1
#         return a
#     return inner
# ret = func()
# r1 = ret()
# print(r1)
# r2 = ret()
# print(r2)

# def func1():
#     print("1")
#
# def func2():
#     print("2")
#
# func1=func2
#
# func1()

# def guanjia(game):
#     def inner():
#         print("打开外挂")
#         game()
#         print("关闭外挂")
#     return inner
#
#
# @guanjia
# def play_dnf():
#     print("你好，DNF")
#
# @guanjia
# def play_lol():
#     print("你好，LOL")
#
# # play_dnf()
# # play_lol()
# # play_dnf=guanjia(play_dnf)
# play_dnf()

# def guanjia(game):
#     #*,**表示接收所有的参数，打包成元祖和字典
#     def inner(*args,**kwargs):#inner添加了参数，args 一定是一个元组，kwargs一定是字典 (admin,123456)
#         print("打开外挂")
#         # *,** 表示把args元组和kwargs字典，打散成位置参数及关键字参数传递出去
#         game(*args,**kwargs)#game(‘admin’,'123456')
#         print("关闭外挂")
#     return inner
#
# @guanjia
# def play_dnf(username,password):
#     print("我要开始玩dnf了",username,password)
#     print("你好，DNF")
#
# @guanjia
# def play_lol(username,password,hero):
#     print("我要开始玩LOL了",username,password,hero)
#     print("你好，LOL")
#
# # play_dnf("admin","123456")
# play_lol("admin","654321","盖伦")

# def guanjia(game):
#     #*,**表示接收所有的参数，打包成元祖和字典
#     def inner(*args,**kwargs):#inner添加了参数，args 一定是一个元组，kwargs一定是字典 (admin,123456)
#         print("打开外挂")
#         # *,** 表示把args元组和kwargs字典，打散成位置参数及关键字参数传递出去
#         ret = game(*args,**kwargs)#game(‘admin’,'123456')
#         print("关闭外挂")
#         return ret
#     return inner
#
# @guanjia
# def play_dnf(username,password):
#     print("我要开始玩dnf了",username,password)
#     print("你好，DNF")
#     return "一把屠龙刀"
#
# def play_lol(username,password,hero):
#     print("我要开始玩LOL了",username,password,hero)
#     print("你好，LOL")
#
# ret = play_dnf("admin","123456")
# print(ret)
# # play_lol("admin","654321","盖伦")

# def wrapper1(fn):
#     def inner(*args,**kwargs):
#         print("这里是wrapper1 进入") #1
#         ret = fn(*args,**kwargs) # warpper2.inner
#         print("这里是wrapper1 出去") #5
#         return ret
#     return inner
#
# def wrapper2(fn):
#     def inner(*args,**kwargs):
#         print("这里是wrapper2 进入") #2
#         ret = fn(*args,**kwargs) #target
#         print("这里是wrapper2 出去") #4
#         return ret
#     return inner
#
# @wrapper1 # target =  wrapper1(wrapper2.inner) ==>target :wrapper1.inner
# @wrapper2 # target =  wrapper2(target) ==>target :wrapper2.inner
# def target():
#     print("我是目标") #3
#
# target()

# login_flag = False
# def login_verify(fn):
#
#     def inner(*args,**kwargs):
#         global login_flag
#         if login_flag ==False:
#             print("还未完成用户登录操作")
#             while 1:
#                 username = input("用户名>>>")
#                 password = input("密码>>>")
#                 if username == "admin" and password == "123":
#                     print("登录成功")
#                     login_flag = True
#                     break
#                 else:
#                     print("登录失败")
#         ret = fn(*args,**kwargs)
#         return ret
#     return inner
#
#
# @login_verify
# def add():
#     print("添加员工信息")
#
# def update():
#     print("修改员工信息")
#
# def delete():
#     print("删除员工信息")
#
# def search():
#     print("查询员工信息")
#
# add()

# for c in "123":
#     print(c)

# def func():
#     print("12355")
#     yield 999
#
# ret =  func()
# print(ret.__next__())

# def func():
#     print(123)
#     yield 666
#     print(456)
#     yield 999
# ret =  func()
# print(ret.__next__())
# print(ret.__next__())

# def order():
#     lst=[]
#     for i in range(10000):
#         lst.append(f"衣服{i}")
#         if len(lst) == 50:
#             yield lst
#             lst =[]
#
# gen = order()
# print(gen.__next__())

# lst = []
# for i in range(10):
#     lst.append(i)
#
# print(lst)

#列表推导式 : [数据 for 循环 if 判断]
# lst1 = [i for i in range(1,10,2)]
# print(lst1)
# lst2 = [i for i in range(10) if i % 2 !=0]
# print(lst2)

# lst =[ f"衣服{i}" for i in range(50)]
# print(lst)

# lst = ["allen","tony","kevin","xixi"]
# lst2 = [item.upper() for item in lst]
# print(lst2)
#集合推导式 : {数据 for 循环 if 判断}
# s = {i for i in range(10)}
# print(s)

#字典推导式 : {k:v for 循环 if 判断}
# lst = ["allen","tony","kevin","xixi"]
# dist = {i:lst[i] for i in range(len(lst))}
# print(dist)

#生成器表达式(数据 for 循环 if 判断)
# gen = (i**2 for i in range(10))
# # for item in gen:
# #     print(item)
# lst = list(gen)
# print(lst)

#lambda 表达式

# def func(a,b):
#     return a+b
#
# fn = lambda a, b:a + b
# print(fn)
# print(fn(11,12))

# lst1 = ["赵本山","范伟","苏有朋"]
# lst2 = [48,42,38]
# lst3 = ["卖拐","耳朵大有福","情深深雨濛濛"]
#
# result = zip (lst1,lst2,lst3)
# s = list(result)
# print(s)

# def func1():
#     a = 188
#     print(locals())
#
# func1()


# lst = [123,34,455,76,1,6,899,333]
# s = sorted(lst,reverse=True)
# print(s)

# lst1 = ["赵本山","范伟","看看火花塞","苏有朋","四块五","球"]
#
# # def func(item):
# #     return len(item)
#
# s = sorted(lst1, key=lambda x: len(x))
# print(s)

# lst = [
#     {"id": 1,"name": "周润发","age":18,"salary":5200},
#     {"id": 2,"name": "周星驰","age":25,"salary":56000},
#     {"id": 3,"name": "周海媚","age":78,"salary":2345},
#     {"id": 4,"name": "周扒皮","age":38,"salary":5533},
#     {"id": 5,"name": "周波提","age":43,"salary":2241},
#     {"id": 6,"name": "周大生","age":35,"salary":11},
#     {"id": 7,"name": "周伯通","age":98,"salary":6545}
# ]
#
# # s = sorted(lst,key = lambda d: d['age'])
# s = sorted(lst,key = lambda d: d['salary'],reverse=True)
# print(s)


# lst = ["张三丰","李斯特","巴拉巴拉小魔仙","张流川枫","海克斯"]
# f = filter(lambda x: not x.startswith("张"), lst)
# print(list(f))

# lst = [1,2,3,4,5,6,7,8,9]
# # result = [item * item for item in list]
#
# r = map(lambda x: x*x, lst)
# print(r)
# print(list(r))